Case study HSRHI for clustering

Scott Collis, Alain Protat, Mariko Oue, Gary Wen


In [1]:
import pyart
from matplotlib import pyplot as plt
import numpy as np
%matplotlib inline

In [2]:
filename = '/data/radar/nsa/BRW130502161611.RAWVGFU'
radar = pyart.io.read(filename)

In [7]:
print radar.fields.keys()


['differential_phase', 'cross_correlation_ratio', 'normalized_coherent_power', 'spectrum_width', 'total_power', 'reflectivity', 'differential_reflectivity', 'specific_differential_phase', 'velocity']

In [27]:
# Lets plot some RHIs

# So first we are going to create a list of pairs of strings..
# these are the two fields to be plotted per line, so in the end we
# have 4 rows and two columns

field_pairs = [['reflectivity', 'velocity'],
               ['differential_reflectivity', 'differential_phase'],
               ['normalized_coherent_power', 'cross_correlation_ratio'],
               ['specific_differential_phase', 'spectrum_width']]

# so this is a list of yuples. (two-tuples to be exact)
# just like the above!
# these are the value ranges for each of the plots.. please feel free to experiment!

range_pairs= [[(-32, 24), (-17.0, 17.0)],
              [(-0.5, 7.0), (100, 170.0)],
              [(0, 1), (.7, 1.0)],
              [(-0.5, 1), (0., 4.0)]]

# just like above, create a new display

display = pyart.graph.RadarDisplay(radar)

# Time to loop folks! Note the way Python deals with
# flow control. Indentation.. Deal with it and I promise
# in the end you will love it. 

# looping is done over a list.. the range() function creates 
# a list from 0 to len(field_pairs)-1

for i in range(len(field_pairs)):
    # fields to plot and ranges
    fields_to_plot = field_pairs[i]  # this is now just a pair of strings
    ranges = range_pairs[i]  # this is now a pair of two-tuples
    
    # plot the data
    nplots = len(fields_to_plot)  # This will be 2
    
    #create a matplotlib figure object
    plt.figure(figsize=[7 * nplots, 3])  # you can play with this! 
    
    # plot each field, so here we loop over the two fields per row
    for plot_num in range(nplots): 
        field = fields_to_plot[plot_num]  # grab the field to be plotted for this panel
        vmin, vmax = ranges[plot_num]  # grab the ranges from the two-Tuple
        
        # The below command is a matplotlib command. This creates
        # subplots (Rows, Columns, and current plot)
        # So on the first execution it is a 1 row 2 column at the 1st position
        # and on the second at the 2nd position 
        plt.subplot(1, nplots, plot_num + 1) 
        display.plot_rhi(field, 0, vmin=vmin, vmax=vmax, title_flag=False)  # and you know this! 
        display.set_limits(ylim=[0, 6])  # feel free to play and to add a xlim below!
    
    # set the figure title
    radar_name = display.radar_name  # grab the name of the radar from the display
    time_text = ' ' + display.time_begin.isoformat() + 'Z ' # the display obj helps you! 
    azimuth = radar.fixed_angle['data'][0] 
    title = 'RHI ' + radar_name + time_text + 'Azimuth %.2f' % (azimuth)
    plt.suptitle(title)


Seems to be only sampling at 1 degree.. Lets check...


In [30]:
fig = plt.figure(figsize = [15,8])
for scan_num in range(len(radar.sweep_start_ray_index['data'])):
    i0 = radar.sweep_start_ray_index['data'][scan_num]
    i1 = radar.sweep_end_ray_index['data'][scan_num]
    plt.plot(radar.time['data'][i0:i1], radar.elevation['data'][i0:i1])



In [32]:
fig = plt.figure(figsize = [15,8])
for scan_num in range(len(radar.sweep_start_ray_index['data'])):
    i0 = radar.sweep_start_ray_index['data'][scan_num]
    i1 = radar.sweep_end_ray_index['data'][scan_num]
    plt.plot(radar.time['data'][i0:i1], radar.elevation['data'][i0:i1])
    plt.plot(radar.time['data'][i0:i1], radar.elevation['data'][i0:i1],'o')
    
plt.gca().set_xlim([90,110])
plt.gca().set_ylim([150,180])


Out[32]:
(150, 180)

In [34]:
fig = plt.figure()
plt.plot(np.diff(radar.elevation['data'][i0:i1]))


Out[34]:
[<matplotlib.lines.Line2D at 0x10a597150>]

So yes.. only oversampling at 2x


In [ ]: